﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using Microsoft.ApplicationBlocks.Data;

namespace TIS.DAO
{
    public class LanguageDAO
    {

        private static readonly String Url = ConfigurationManager.AppSettings["Main.ConnectionString"];
        public LanguageDAO()
        {

        }

        private SqlConnection _connection;
        private SqlConnection GetConnection()
        {

            _connection = new SqlConnection(Url);
            if (_connection.State == ConnectionState.Closed)
            {
                _connection.Open();
            }

            return _connection;
        }

        public DataTable GetAllLanguage()
        {
            try
            {
                _connection = GetConnection();
                DataSet ds = SqlHelper.ExecuteDataset(_connection, CommandType.Text, "SELECT * FROM Language");
                return ds.Tables[0];
            }
            finally
            {
                _connection.Close();
            }
        }
    }
}